
package com.phevos.common.util;


import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

public class PropertiesUtil
{
    private PropertiesUtil()
    {
    }

    /**
     * ����properties�ļ�<filename>�е�Properties
     * 
     * @param filename
     * @return Properties
     * @throws IOException �������ļ���д����ʱ
     * @throws FileNotFoundException ���ļ���Ϊnull,�մ�,�����ļ�������ʱ
     */
    public static Properties getProperties(String filename) throws IOException,
            FileNotFoundException
    {
        if (filename == null || filename.trim().length() == 0)
        {
            throw new FileNotFoundException("Files Name can't be null or String of length 0.");
        }
        FileInputStream configStream = null;
        Properties prop = new Properties();
        try
        {
            configStream = new FileInputStream(filename);
            prop.load(configStream);
        }
        finally
        {
            if (null != configStream)
            {
                try
                {
                    configStream.close();
                }
                catch (Throwable t)
                {
                    t.getMessage();
                }
            }
        }/*
             * ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); prop.load(
             * classLoader.getResourceAsStream(filename) );
             */
        return prop;
    }
}
